package com.kaibes.core.base.tag;

import java.util.HashMap;
import java.util.Map;

public class TagObjects {
    
    private final static Map<Object, TagObject> objectMap = new HashMap<>();

    public final static TagObject justCreate(Object target) {
        return new TagObject(target);
    }

    public final static TagObject createObject(Object target) {
        TagObject result;
        if (objectMap.containsKey(target)) {
            result = objectMap.get(target);
        } else {
            result = new TagObject(target);
            objectMap.put(target, result);
        }
        return result;
    }
    
    public final static TagObject getObject(Object target) {
        return objectMap.get(target);
    }
    
    public static void remove(Object target) {
        objectMap.remove(target);
    }
    
    public static void clear() {
        objectMap.clear();
    }
}
